/**
 * 
 */
package com.geezdata.cps.sdk3rd.wechat.method;

import java.util.Map;

import com.geezdata.cps.sdk3rd.wechat.request.WechatShortUrlRequest;
import com.geezdata.cps.sdk3rd.wechat.response.WechatShortUrlResult;
import com.google.common.collect.Maps;

/**
 * @author sszheng
 * @date 创建时间：2018年4月10日 下午5:15:27
 *
 */
public class WechatShortUrl extends BaseWechat implements Wechat<WechatShortUrlRequest, WechatShortUrlResult>{
	private static final String SHORT_URL_URL = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=";

	@Override
	public WechatShortUrlResult execute(WechatShortUrlRequest request) {
		Map<String, Object> params = prepareParams(request);
		return doPost(SHORT_URL_URL + request.getToken(), params, WechatShortUrlResult.class);
	}
	
	private Map<String, Object> prepareParams(WechatShortUrlRequest request) {
		Map<String, Object> map = Maps.newHashMap();
		map.put("action", request.getAction());
		map.put("long_url", request.getLongUrl());
		return map;
	}

}
